/**
 * 
 */
package com.repository.controller;

import java.io.StringWriter;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;

import junit.framework.TestCase;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Before;
import org.junit.Test;
import org.junit.internal.runners.JUnit4ClassRunner;
import org.junit.runner.RunWith;

import com.repository.model.User;

/**
 * @author lovkeshsingh
 *
 */
public class XMLSerializationTestCases{
	
	Log log = LogFactory.getLog(XMLSerializationTestCases.class);
	
	@Before
	public void setupMethod(){
		System.out.println("setupMethod");
	}

	@Test
	public void testXMLSerialization() throws JAXBException{
		
		System.out.println("testXML");
		
		User user = new User(10,"lovkesh", "sunshine56");
		
		JAXBContext jaxbCtx = JAXBContext.newInstance(User.class);
		
		StringWriter writer = new StringWriter();
		
		jaxbCtx.createMarshaller().marshal(user, writer);
		
		String xml = writer.toString();
		
		System.out.println(xml);
		
	}
}
